package com.zl.smartmall.library.listener;

import org.apache.http.Header;
import org.json.JSONObject;

import com.loopj.android.http.JsonHttpResponseHandler;

/**
 * 数据请求监听基类, 其他监听器直接继承此类就行
 * @author 陈希然
 *
 */
public abstract class BaseListener extends JsonHttpResponseHandler {

	protected RequestCode requestCode;
	/**
	 * 无数据可供加载
	 */
	public abstract void onNoMoreData();
	/**
	 * 无网络连接
	 */
	public abstract void onNoNetWork();
	/**
	 * 离线状态
	 */
	public abstract void onOffline();
	/**
	 * 数据请求失败
	 */
	public abstract void onResponseFailed();
	
	public BaseListener() {
		requestCode = RequestCode.CACHE;
	}
	public BaseListener(RequestCode requestCode) {
		this.requestCode =  requestCode;
	}
	
	@Override
	public void onFailure(int statusCode, Header[] headers,
			String responseString, Throwable throwable) {
		// TODO Auto-generated method stub
		onFailure(statusCode, headers, throwable, new JSONObject());
	}
	
	public RequestCode getRequestCode() {
		return requestCode;
	}

	public void setRequestCode(RequestCode requestCode) {
		this.requestCode = requestCode;
	}
}
